package main

import "fmt"

// 结构体嵌套

type address struct {
	province string
	city     string
}

type workspace struct {
	province string
	city     string
}

type person struct {
	name    string
	age     int
	address // 匿名嵌套结构体
	workspace
}

type company struct {
	name string
	address
}

func main() {
	p1 := person{
		name: "周周",
		age:  90,
		address: address{
			province: "重庆",
			city:     "大渡口",
		},
	}
	fmt.Println(p1)
	fmt.Println(p1.name, p1.address.city)
	// fmt.Println(p1.city) // 现在自己结构体找这个字段，找不到就去嵌套的匿名结构体中找
	fmt.Println(p1.workspace.city)
}
